<template>
    <!-- pages/order/index.wxml -->
    <view class="order">
		<view class="head-block" v-if="weixin == 2">
				     <view class="nav-title" :style="'top:10px'"></view>
					 <!-- 返回 -->
					 <view class="icons" @tap="goMy" :style="'top:6px'">
					      <van-icon name="arrow-left" color="#333" size="45rpx" />
					  </view>
				 </view>
        <view class="order-body">
            <van-tabs :active="active" :data-active="active" @change="onChange($event, { active })">
                <van-tab title="包月订单">
                    <view v-if="list && list.length > 0">
                        <view v-for="(item, key) in list" :key="item.key">
                            <view class="card">
                                <view class="card-header">
                                    <view class="card-header-text">
                                        <span>订单明细</span>
                                    </view>
                                    <view>
                                        <view v-if="item.orderStatus === 105 || item.orderStatus === 106">
                                            <!-- <image src='/assets/img/icon1.png' /> -->
                                            <view class="card-header-icon-text text-red">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 104">
                                            <!-- <image src='/assets/img/icon2.png' /> -->
                                            <view class="card-header-icon-text text-gray">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 101 || item.orderStatus === 102">
                                            <!-- <image src='/assets/img/icon4.png' /> -->
                                            <view class="card-header-icon-text text-red">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 108 || item.orderStatus === 103 || item.orderStatus === 109">
                                            <!-- <image src='/assets/img/icon5.png' /> -->
                                            <view class="card-header-icon-text">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 107 || item.orderStatus === 110">
                                            <!-- <image src='/assets/img/icon2.png' /> -->
                                            <view class="card-header-icon-text text-gray">{{ item.typeStatus }}</view>
                                        </view>
                                    </view>
                                </view>
                                <view class="card-order">
                                    <view class="card-order-l">
                                        <view class="card-order-l-t new-blt">
                                            <view class="card-order-spname">{{ item.parkingName }}</view>
                                            <view class="card-order-spnum">
                                                <view class="spnum-fixtext">车位</view>
                                                <view class="spnum-num">{{ item.parkingSpaceNo }}</view>
                                            </view>
                                        </view>
                                        <view class="card-order-l-c">
                                            <view class="card-order-l-text">预约时段：</view>
                                            <view class="card-order-l-content">
                                                <view>{{ item.startTime }}~</view>
                                                <view>{{ item.endTime }}</view>
                                            </view>
                                        </view>
                                        <view class="card-order-l-c">
                                            <view class="card-order-l-text">使用车辆：</view>
                                            <view class="card-order-l-content">
                                                <view>{{ item.plateNo }}</view>
                                            </view>
                                        </view>
                                        <view class="card-order-l-btns">
                                            <view
                                                class="contact-btn"
                                                @tap="gotoMessage"
                                                :data-data="item"
                                                :data-url="'../socks/socks?manageId=' + (item.manageId ? item.manageId : '')"
                                            >
                                                <image src="../../static/assets/img/message.png" class="img-msg"></image>
                                                <view>留言咨询</view>
                                            </view>
                                            <view class="contact-btn" @tap="handlePhoneWy2" :data-id="item.id">
                                                <image src="../../static/assets/img/phone-blue.png" class="img-phone"></image>
                                                <view>联系电话</view>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                                <view class="card-footer">
                                    <view class="card-footer-l">
                                        <view class="card-footer-left-text">
                                            订单金额：
                                            <text class="footer-left-text-unit">￥</text>
                                            <text class="footer-left-text-price">{{ item.money / 100 }}</text>
                                            元
                                        </view>
                                    </view>
                                    <view class="card-footer-btn-dob">
                                        <view :class="'confirmBtn ' + (item.isInputCar == 1 ? 'bg-gray' : '')" :data-data="item" @tap="confirmPlate">
                                            {{ item.isInputCar == 1 ? '已确认' : '请确认车牌录入' }}
                                        </view>
                                    </view>
                                    <!-- <view class="card-footer-btn-dob" wx:if="{{item.orderStatus===105 || item.orderStatus===106}}">
                                <view class="card-footer-btn qx" data-id="{{item.id}}" bindtap="cancelApply">
                                    申请退租
                                </view>
                                <view class="card-footer-btn lxcz" data-id="{{item.id}}" bindtap="showPopup">
                                    联系对方
                                </view>
                            </view>
                            <view class="card-footer-btn-dob" wx:if="{{item.orderStatus === 108}}">
                                <view class="card-footer-btn qx" bindtap="cancelwithdraw">
                                    取消申请
                                </view>
                                <view class="card-footer-btn lxcz" data-id="{{item.id}}" bindtap="showPopup">
                                    联系对方
                                </view>
                            </view>
                            <view wx:if="{{item.orderStatus === 107 || item.orderStatus === 110}}" data-orderid="{{item.id}}" class="card-footer-btn pj" data-id="{{item.id}}" bindtap="handleeValuate">
                                评价车主
                            </view> -->
                                    <!-- <view class="card-footer-btn lxcz" data-id="{{item.id}}" bindtap="showPopup">
                                联系对方
                            </view> -->
                                    <!-- <view wx:if="{{item.orderStatus === 109}}" class="card-footer-btn pj">
                                <view class="card-footer-btn lxcz" data-id="{{item.id}}" data-type="{{1}}" bindtap="cancelReply">
                                    同意退租
                                </view>
                                <view class="card-footer-btn lxcz" data-id="{{item.id}}" data-type="{{0}}" bindtap="cancelReply">
                                    拒绝退租
                                </view>
                                <view class="card-footer-btn lxcz" data-id="{{item.id}}" bindtap="showPopup">
                                    联系对方
                                </view>
                            </view> -->
                                    <!-- <view wx:if="{{item.type==='用户申请退款中'}}" class="card-footer-btn qx">
                                更多操作
                            </view> -->
                                </view>
                            </view>
                        </view>
                    </view>
                    <view v-else>
                        <view class="nopark">
                            <image src="../../static/assets/img/empty.png"></image>
                        </view>
                        <view class="text">暂无数据</view>
                    </view>
                </van-tab>
                <van-tab title="临停订单">
                    <view v-if="list && list.length > 0">
                        <view v-for="(item, key) in list" :key="item.key">
                            <view class="card">
                                <view class="card-header">
                                    <view class="card-header-text">
                                        <span>订单明细</span>
                                    </view>
                                    <view>
                                        <view v-if="item.orderStatus === 2 || item.orderStatus === 1 || item.orderStatus === 7">
                                            <!-- <image src='/assets/img/icon1.png' style="width:120rpx" /> -->
                                            <view class="card-header-icon-text text-orange">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 4 || item.orderStatus === 5">
                                            <!-- <image src='/assets/img/icon4.png' /> -->
                                            <view class="card-header-icon-text text-red">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 6">
                                            <!-- <image src='/assets/img/icon5.png' /> -->
                                            <view class="card-header-icon-text text-red">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 3">
                                            <!-- <image src='/assets/img/icon2.png' /> -->
                                            <view class="card-header-icon-text">{{ item.typeStatus }}</view>
                                        </view>
                                        <view v-if="item.orderStatus === 8 || item.orderStatus === 9">
                                            <!-- <image src='/assets/img/icon2.png' /> -->
                                            <view class="card-header-icon-text text-gray">{{ item.typeStatus }}</view>
                                        </view>
                                    </view>
                                </view>
                                <view class="card-order">
                                    <view class="card-order-l">
                                        <!-- <view class="card-order-l-t">{{item.parkingName}}</view>
                                <view class="card-order-l-c">
                                    <image src='/assets/img/timeicon.png' />
                                    <view class="card-order-l-text">停车时间</view>
                                    <view class="card-order-l-content">{{item.planTime}}</view>
                                </view>
                                <view class="card-order-l-c">
                                    <image src='/assets/img/caricon.png' />
                                    <view class="card-order-l-text">预约车辆</view>
                                    <view class="card-order-l-content">{{item.plateNo}}</view>
                                </view> -->
                                        <view class="card-order-l-t new-blt">
                                            <view class="card-order-spname">{{ item.parkingName }}</view>
                                            <view class="card-order-spnum">
                                                <view class="spnum-fixtext">车位</view>
                                                <view class="spnum-num">{{ item.parkingSpaceNo }}</view>
                                            </view>
                                        </view>
                                        <view class="card-order-l-c">
                                            <view class="card-order-l-text">预约日期：</view>
                                            <view class="card-order-l-content">
                                                <view>{{ item.startTime }}</view>
                                                <!-- <view>~{{item.endTime}}</view> -->
                                            </view>
                                        </view>
                                        <!-- <view class="card-order-l-c">
                                        <view class="card-order-l-text">计费时段：</view>
                                        <view class="card-order-l-content">
                                            <view>{{item.tmpArriveTime || ''}}~</view><view>{{item.tmpEndTime || ''}}</view>
                                        </view>
                                </view> -->
                                        <view class="card-order-l-c">
                                            <view class="card-order-l-text">使用车辆：</view>
                                            <view class="card-order-l-content">
                                                <view>{{ item.plateNo }}</view>
                                            </view>
                                        </view>
                                        <view class="card-order-l-btns">
                                            <view
                                                class="contact-btn"
                                                @tap="gotoMessage"
                                                :data-data="item"
                                                :data-url="'../socks/socks?manageId=' + (item.manageId ? item.manageId : '')"
                                            >
                                                <image src="../../static/assets/img/message.png" class="img-msg"></image>
                                                <view>留言咨询</view>
                                            </view>
                                            <view class="contact-btn" @tap="handlePhoneWy2" :data-id="item.id">
                                                <image src="../../static/assets/img/phone-blue.png" class="img-phone"></image>
                                                <view>联系电话</view>
                                            </view>
                                        </view>
                                    </view>
                                </view>
                                <view class="border"></view>
                                <view class="card-footer">
                                    <view class="card-footer-l">
                                        <view class="card-footer-left-text">
                                            订单金额：
                                            <text class="footer-left-text-unit">￥</text>
                                            <text class="footer-left-text-price">{{ item.money / 100 }}</text>
                                            元
                                        </view>
                                        <!-- <view class="card-order-l-text">预约车辆</view>
                                <view class="card-order-l-content">{{item.wdyj}}</view> -->
                                    </view>
                                    <!-- <view wx:if="{{item.orderStatus !== 7 && item.orderStatus !== 3}}" class="card-footer-btn lxcz" data-id="{{item.id}}" bindtap="showPopup">
                                联系对方
                            </view>
                            <view wx:if="{{item.orderStatus === 7}}" class="card-footer-btn pj" data-id="{{item.id}}" bindtap="handleeValuate">
                                评价车主
                            </view> -->
                                </view>
                            </view>
                        </view>
                    </view>
                    <view v-else>
                        <view class="nopark">
                            <image src="../../static/assets/img/empty.png"></image>
                        </view>
                        <view class="text">暂无数据</view>
                    </view>
                </van-tab>
            </van-tabs>
            <view class="mySpaceProfit">{{ active == 0 ? '包月' : '临停' }}订单合计{{ mySpaceProfit.num }}笔，总收益{{ mySpaceProfit.actualPay / 100 }}元</view>
        </view>
        <!-- 联系对方弹窗 -->
        <van-popup v-model="show" position="bottom" round @close="onClose">
            <view class="pop-container">
                <view class="pop-c-text" @tap="handlePopphone">电话联系</view>
                <view class="pop-c-message" @tap="showtextPopup">信息联系</view>
                <view class="pop-c-canel" @tap="onClose">取消</view>
            </view>
        </van-popup>
        <van-popup v-model="showMessage" position="bottom" round @close="onCloseMessage">
            <view class="pop-container">
                <view class="pop-c-text" @tap="handlePopphone">联系对方</view>
                <view class="pop-c-message" @tap="showtextPopup">同意退租</view>
                <view class="pop-c-message" @tap="showRefuse">拒绝退租</view>
                <view class="pop-c-canel" @tap="onClose">取消</view>
            </view>
        </van-popup>
        <!-- 信息提示弹窗 -->
        <van-dialog
            use-slot
            title="信息留言"
            v-model="textShow"
            round-button
            show-cancel-button
            confirm-button-open-type="getUserInfo"
            @close="ontextClose"
            @getuserinfo="getUserInfo"
            class="popup"
            confirm-button-color="#00BCAB"
        >
            <van-cell-group>
                <van-field v-model="message" label="留言" type="textarea" placeholder="请输入留言" autosize :border="false" />
            </van-cell-group>
        </van-dialog>
        <!-- 评价弹出框 -->
        <van-dialog
            use-slot
            title="请为车主评分"
            v-model="Valuateshow"
            show-cancel-button
            confirm-button-open-type="getUserInfo"
            @close="onCloseValuate"
            @confirm="getUserInfoValuate"
            class="popup"
            confirm-button-color="#00BCAB"
        >
            <van-rate readonly v-model="valueRate" :size="25" color="#FF9800;" void-color="#eee" void-icon="star" @change="onChangeValueRate" />
            <van-field v-model="Valuatemessage" label="留言" type="textarea" placeholder="请输入留言" autosize :border="false" @change="changeValuatemessage" />
        </van-dialog>
        <!-- 取消预约 -->
        <van-dialog id="van-dialog" confirm-button-color="#00BCAB" />
        <!-- 拒绝退租弹窗 -->
        <van-dialog id="van-dialog" />
    </view>
</template>

<script>
import util from './../../utils/util.js';
import api from './../../utils/api.js'; // import Dialog from "@vant/weapp/dist/dialog/dialog";
import { Dialog } from 'vant';
export default {
    data() {
        return {
            autoplay: false,

            // unionId: "fb0feca5-0945-4989-b4aa-8c33413ff648",
            // unionId: wx.getStorageSync("unionId") || "",
            list: [],

            banner: [],
            value1: 0,
            valueCar: '浙AAAA',

            //显示车牌号
            show: false,

            //联系车主弹窗
            textShow: false,

            //留言
            message: '',

            //留言
            Valuatemessage: '',

            //评价留言
            Valuateshow: false,

            //评价
            valueRate: 1,

            //评分
            cancelshow: false,

            //取消预约
            showMessage: false,

            //更多操作
            personType: 2,

            //人员类型 1车位｜2车为主//我的小区查询的就是车位主
            parkingSpace: '',

            active: 0,

            //tab切换
            carOrderLogId: '',

            //订单号
            currentbanner: 0,

            phoneNumber: null,

            temp: [
                {
                    id: 40,
                    parkingNumber: 'c116',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 53,
                        state: 1,
                        createTime: '2021-10-28 14:44:19',
                        modifiedTime: '2021-10-29 20:47:54',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c116',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '02:00:00',
                        tempEndTime: '23:59:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: 1635511674000,
                        fiveColorId: null
                    }
                },
                {
                    id: 41,
                    parkingNumber: 'c119',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 54,
                        state: 1,
                        createTime: '2021-10-28 14:45:05',
                        modifiedTime: '2021-10-29 20:18:56',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c119',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '06:00',
                        tempEndTime: '23:01',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 42,
                    parkingNumber: 'c120',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 55,
                        state: 1,
                        createTime: '2021-10-28 14:45:38',
                        modifiedTime: '2021-10-29 19:34:57',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c120',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '06:00:00',
                        tempEndTime: '22:01:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 46,
                    parkingNumber: 'c127',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 56,
                        state: 1,
                        createTime: '2021-10-28 18:45:17',
                        modifiedTime: '2021-10-29 20:18:53',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c127',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-28 00:00:00',
                        validEndTime: '2021-11-28 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '12:00:00',
                        tempEndTime: '23:01:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 49,
                    parkingNumber: 'c131',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 1,
                    plmParkingSpaceManage: {
                        id: 58,
                        state: 1,
                        createTime: '2021-10-29 10:02:29',
                        modifiedTime: '2021-10-29 20:18:34',
                        creator: null,
                        modifier: 347,
                        creatorName: null,
                        modifierName: '支国庆',
                        ownerId: 8,
                        identityId: 664,
                        spaceNo: 'c131',
                        spaceSum: 1,
                        parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                        spaceOwnerType: 1,
                        phone: '18658195007',
                        isTemp: 1,
                        monthType: 0,
                        validStartTime: '2021-10-29 00:00:00',
                        validEndTime: '2021-11-29 00:00:00',
                        tempCycle: '1111111',
                        tempStartTime: '02:00:00',
                        tempEndTime: '23:56:00',
                        tempCrossDay: 0,
                        monthNightStartTime: null,
                        monthNightEndTime: null,
                        parkingRequire: 0,
                        saleStatus: 1,
                        saleTime: null,
                        fiveColorId: null
                    }
                },
                {
                    id: 6,
                    parkingNumber: 'a01',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 45,
                    parkingNumber: 'c122',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 47,
                    parkingNumber: 'c129',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                },
                {
                    id: 48,
                    parkingNumber: 'c130',
                    parkingCode: 'aa678e13-8183-4045-ac00-0f1dd0503061',
                    parkingName: '君景庭',
                    address: '杭州市滨江区东信大道与六和路交叉口东南50米',
                    authStatus: 1,
                    saleStatus: 0,
                    plmParkingSpaceManage: null
                }
            ],

            parkingCode: '',
            spaceNo: '',
            activeOrderId: '',

            mySpaceProfit: {
                num: '',
                actualPay: 0
            },

            saleStatus: 0,
			weixin:uni.getStorageSync('weixin')
        };
    },
    onLoad: function (options) {
        if (options.parkingCode) {
            this.setData({
                parkingCode: options.parkingCode
            });
        }

        if (options.spaceNo) {
            this.setData({
                spaceNo: options.spaceNo
            });
        }

        this.getmySpaceList();
        this.getmySpaceProfit();
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    // onShareAppMessage: function() {}
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */ methods: {
        handleBanner(e) {
            this.setData({
                active: 0,
                parkingSpace: this.banner[e.detail.current].parkingNumber,
                currentbanner: e.detail.current
            });
            this.getmyCarOrderLog();
            this.getmySpaceProfit();
        },

        change({ detail }) {
            this.setData({
                value1: detail,
                valueCar: this.option1.find((e) => e.value === detail).text
            });
        },

        //联系车主弹窗
        showPopup(e) {
            // console.log("showPopup");
            this.setData({
                show: true,
                carOrderLogId: e.currentTarget.dataset.id
            });
        },
		goMy() {
		     uni.navigateBack({
		         delta: 1
		     });
		 },
        //联系方式
        getcall() {
            const unionId = uni.getStorageSync('unionId') || '';
            util.request(api.call + '?carOrderLogId=' + this.carOrderLogId + '&userUnionId=' + unionId + '&type=1', 'get').then((res) => {
                if (res.code == 0) {
					if(uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4){
						ZWJSBridge.phoneCall({
						  "corpId": res.data
						}).then(res => {
						  console.log(res)
						}).catch(err => {
						  console.log(err) 
						})
					}else{
						uni.makePhoneCall({
							phoneNumber: res.data
						}).catch((e) => {
							console.log(e);
						});
					}
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }
            });
        },

        onClose() {
            this.setData({
                show: false
            });
        },

        //弹出层电话
        handlePopphone() {
            this.getcall();
        },

        //留言
        getUserInfo(event) {
            // console.log(event.detail);
        },

        showtextPopup() {
            // console.log(this.data.textShow);
            this.setData({
                textShow: true
            });
            this.setData({
                show: false
            });
        },

        ontextClose() {
            this.setData({
                textShow: false
            });
        },

        //请评价
        handleeValuate(e) {
            this.setData({
                Valuateshow: true,
                activeOrderId: e.currentTarget.dataset.orderid
            });
        },

        onCloseValuate() {
            this.setData({
                Valuateshow: false
            });
        },

        onChangeValueRate(e) {
            this.setData({
                valueRate: e.detail
            });
        },

        changeValuatemessage(e) {
            this.setData({
                Valuatemessage: e.detail
            });
        },

        getUserInfoValuate(event) {
            const unionId = uni.getStorageSync('unionId') || '';
            const { activeOrderId, valueRate, Valuatemessage } = this;
            const param = {
                orderId: activeOrderId,
                userUnionId: unionId,
                evaluateScore: valueRate,
                evaluateContent: Valuatemessage
            };
            util.request(api.userEvaluate, param, 'post').then((res) => {
                if (res.code == 0) {
                    uni.showToast({
                        title: res.msg,
                        icon: 'success'
                    });
                } else {
                    uni.showToast({
                        title: res.msg,
                        icon: 'none'
                    });
                }

                this.setData({
                    activeOrderId: null,
                    valueRate: 1,
                    Valuatemessage: ''
                });
            });
        },

        //取消申请退租
        cancelwithdraw() {
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '取消申请',
                message: '是否确认取消申请？'
            }).then((res) => {
                util.request(api.withdraw + `?userUnionId=${unionId}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        // 申请退租
        cancelApply(e) {
            const carOrderLogId = e.currentTarget.dataset.id;
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '申请退租',
                message: '是否确认申请退租？'
            }).then((res) => {
                util.request(api.cancelApply + `?carOrderLogId=${carOrderLogId}&userUnionId=${unionId}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        // 同意/拒绝退租
        cancelReply(e) {
            const carOrderLogId = e.currentTarget.dataset.id;
            const type = e.currentTarget.dataset.type;
            const unionId = uni.getStorageSync('unionId') || '';
            Dialog.confirm({
                title: '退租处理',
                message: `是否${type ? '同意' : '拒绝'}退租？`
            }).then((res) => {
                util.request(api.cancelReply + `?carOrderLogId=${carOrderLogId}&userUnionId=${unionId}&replyResult=${type}`, 'get').then((res) => {
                    if (res.code == 0) {
                        this.getmyCarOrderLog();
                        uni.showToast({
                            title: res.data,
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                });
            });
        },

        //取消预约弹窗
        handleCancel(e) {
            // console.log(e, "aaa");
            Dialog.confirm({
                title: '标题',
                message: '是否取消预约'
            })
                .then(() => {
                    // on confirm
                })
                .catch(() => {
                    // on cancel
                });
        },

        //我的收益
        getmySpaceProfit() {
            const unionId = uni.getStorageSync('unionId') || '';
            var param = {
                unionId: unionId,
                type: this.active == 0 ? 2 : 1,
                //1临停2包月
                spaceNo: this.spaceNo,
                parkingCode: this.parkingCode
            };
            util.request(api.mySpaceProfit, param, 'POST').then((res) => {
                if (res.code == 0) {
                    this.setData({
                        mySpaceProfit: res.data
                    });
                }
            });
        },

        //我的车位
        getmySpaceList() {
            const unionId = uni.getStorageSync('unionId') || '';
            util.request(api.mySpaceList + '?userUnionId=' + unionId, 'get').then((res) => {
                if (res.code == 0) {
                    let lists = res.data; // let lists = this.data.temp

                    lists &
                        lists.map((e) => {
                            if (e.plmParkingSpaceManage != null) {
                                //包月的显示 全天（默认）
                                if (e.plmParkingSpaceManage.tempCycle == '0000000' || e.plmParkingSpaceManage.tempCycle == null) {
                                    e.addCycleName = '不重复';
                                } else if (e.plmParkingSpaceManage.tempCycle == '1111111') {
                                    e.addCycleName = '每天';
                                } else {
                                    let cy = e.plmParkingSpaceManage.tempCycle.split('');
                                    e.addCycleName = '每周';

                                    if (cy[0] == 1) {
                                        e.addCycleName += '一、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[1] == 1) {
                                        e.addCycleName += '二、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[2] == 1) {
                                        e.addCycleName += '三、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[3] == 1) {
                                        e.addCycleName += '四、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[4] == 1) {
                                        e.addCycleName += '五、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[5] == 1) {
                                        e.addCycleName += '六、';
                                    } else {
                                        e.addCycleName += '';
                                    }

                                    if (cy[6] == 1) {
                                        e.addCycleName += '日';
                                    } else {
                                        e.addCycleName += '';
                                    }
                                }

                                e.plmParkingSpaceManage.validStartTime = e.plmParkingSpaceManage.validStartTime.toString().split(' ')[0] || '';
                                e.plmParkingSpaceManage.validEndTime = e.plmParkingSpaceManage.validEndTime.toString().split(' ')[0] || '';
                            }
                        }); // console.log(lists)

                    let newLists =
                        lists &&
                        lists.filter((item) => {
                            return item.authStatus == 1;
                        });
                    console.log(newLists);
                    this.setData({
                        banner: newLists,
                        parkingSpace: res.data.length ? res.data[this.currentbanner].parkingNumber : ''
                    });
                    this.getmyCarOrderLog(); // console.log(res.data[0].parkingNumber, "aasa");
                }
            });
        },

        //tab切换
        onChange(e, _dataset) {
            /* ---处理dataset begin--- */
            this.datasetHandle(e, _dataset);
            /* ---处理dataset end--- */
            this.setData({
                active: e.detail.index
            });
            this.getmyCarOrderLog();
            this.getmySpaceProfit();
        },

        //上下架
        handlechangeSaleStatus(e) {
            console.log(e);

            if (e.currentTarget.dataset.value.saleStatus === 0) {
                this.setData({
                    saleStatus: 1
                });
                Dialog.confirm({
                    message: '是否确定上架？'
                })
                    .then(() => {
                        this.getchangeSaleStatus(e.currentTarget.dataset.value); // this.getmySpaceList();
                    })
                    .catch(() => {
                        // on cancel
                    });
            } else {
                this.setData({
                    saleStatus: 0
                });
                Dialog.confirm({
                    message: '是否确定下架？'
                })
                    .then(() => {
                        this.getchangeSaleStatus(e.currentTarget.dataset.value); // this.getmySpaceList(); //移到上面的请求中
                    })
                    .catch(() => {
                        // on cancel
                    });
            }
        },

        //编辑
        handleedit(e) {
            let type = e.currentTarget.dataset.value.plmParkingSpaceManage;
            var param = e.currentTarget.dataset.value.id;
            console.log(param);
            let curServiceType = type.isTemp == 1 ? 0 : type.monthType != 0 ? 1 : 0; // 0临停  1包月
            // console.log(e.currentTarget.dataset)

            uni.navigateTo({
                url: '../setParking1/index?id=' + param + '&active=' + curServiceType
            });
        },

        //上下架接口
        getchangeSaleStatus(item) {
            const unionId = uni.getStorageSync('unionId') || '';
            const param = {
                userUnionId: unionId,
                spaceNo: item.parkingNumber,
                parkingCode: item.parkingCode,
                saleStatus: this.saleStatus
            };
            util.request(api.changeSaleStatus, param, 'POST')
                .then((res) => {
                    if (res.code == 0) {
                        uni.showToast({
                            title: res.data,
                            icon: 'none'
                        });
                        this.getmySpaceList();
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                })
                .catch((err) => {
                    uni.showToast({
                        title: '请求异常，请重试',
                        icon: 'none'
                    });
                });
        },

        //我的订单列表查询（车主|车位主）
        getmyCarOrderLog() {
            const unionId = uni.getStorageSync('unionId') || '';
            const param = {
                userUnionId: unionId,
                personType: this.personType,
                orderType: this.active == 0 ? 2 : 1,
                //1临停2包月
                pageNo: 1,
                pageSize: 100,
                parkingSpace: this.spaceNo,
                //车位号，人员类型是车位主的时候必传
                parkingCode: this.parkingCode
            };
            util.request(api.myCarOrderLog, param, 'POST').then((res) => {
                if (res.code == 0) {
                    if (res.data && res.data.length > 0) {
                        res.data.forEach((e) => {
                            if (e.orderStatus == 1 || e.orderStatus == 2 || e.orderStatus == 7 || e.orderStatus == 105 || e.orderStatus == 106) {
                                e.typeStatus = '预约中';
                            } else if (e.orderStatus == 3) {
                                e.typeStatus = '已取消';
                            } else if (e.orderStatus == 4 || e.orderStatus == 5 || e.orderStatus == 101 || e.orderStatus == 102) {
                                e.typeStatus = '待支付';
                            } else if (e.orderStatus == 8 || e.orderStatus == 107) {
                                e.typeStatus = '已完成';
                            } else if (e.orderStatus == 104 || e.orderStatus == 9) {
                                e.typeStatus = '订单关闭';
                            } // if (e.orderStatus == 1) {
                            //   e.typeStatus = "预约中";
                            // } else if (e.orderStatus == 2) {
                            //   e.typeStatus = "使用中";
                            // } else if (e.orderStatus == 3) {
                            //   e.typeStatus = "已取消";
                            // } else if (e.orderStatus == 4) {
                            //   e.typeStatus = "待支付";
                            // } else if (e.orderStatus == 5) {
                            //   e.typeStatus = "支付中";
                            // } else if (e.orderStatus == 6) {
                            //   e.typeStatus = "支付失败待重新支付";
                            // } else if (e.orderStatus == 7) {
                            //   e.typeStatus = "支付成功";
                            // } else if (e.orderStatus == 101) {
                            //   e.typeStatus = "待支付";
                            // } else if (e.orderStatus == 102) {
                            //   e.typeStatus = "支付中";
                            // } else if (e.orderStatus == 103) {
                            //   e.typeStatus = "支付失败待重新支付";
                            // } else if (e.orderStatus == 104) {
                            //   e.typeStatus = "订单关闭";
                            // } else if (e.orderStatus == 105) {
                            //   e.typeStatus = "支付成功";
                            // } else if (e.orderStatus == 106) {
                            //   e.typeStatus = "预约中";
                            // } else if (e.orderStatus == 107) {
                            //   e.typeStatus = "已完成";
                            // } else if (e.orderStatus == 108) {
                            //   e.typeStatus = "申请退租中";
                            // } else if (e.orderStatus == 109) {
                            //   e.typeStatus = "车位主申请退租中";
                            // } else if (e.orderStatus == 110) {
                            //   e.typeStatus = "已退租";
                            // }

                            if (e.durationUnit == 1) {
                                e.dw = '年';
                            } else if (e.durationUnit == 2) {
                                e.dw = '个月';
                            } else if (e.durationUnit == 3) {
                                e.dw = '日';
                            } else if (e.durationUnit == 4) {
                                e.dw = '小时';
                            } else if (e.durationUnit == 5) {
                                e.dw = '分钟';
                            }
                        });
                    }

                    this.setData({
                        list: res.data
                    });
                }
            }); // /***新的查询接口 */
            // let param = {
            // }
            // util.request(api.orderOverview,param,'GET').then(res=>{
            //   if(res.success){
            //     this.setData({
            //             list: res.data
            //     });
            //   }else{
            //     wx.showToast({
            //       title: res.msg || '接口出错了',
            //       icon:'none'
            //     })
            //   }
            // })
            // .catch(err=>{
            //   wx.showToast({
            //     title: '接口出错了',
            //     icon:'none'
            //   })
            // })
        },

        handlePhoneWy(e) {
			if(uni.getStorageSync('weixin') == 3 || uni.getStorageSync('weixin') == 4){
				ZWJSBridge.phoneCall({
				  "corpId": e.currentTarget.dataset.id.toString()
				}).then(res => {
				  console.log(res)
				}).catch(err => {
				  console.log(err) 
				})
			}else{
				uni.makePhoneCall({
					phoneNumber: e.currentTarget.dataset.id.toString()
				}).catch((e) => {
					console.log(e);
				});
			}
        },

        handlePhoneWy2(e) {
            const unionId = uni.getStorageSync('unionId') || '';
            util.request(api.call + '?carOrderLogId=' + e.currentTarget.dataset.id.toString() + '&userUnionId=' + unionId + '&type=1', 'get').then((res) => {
                if (res.code == 0) {
                    uni.makePhoneCall({
                        phoneNumber: res.data
                    }).catch((e) => {
                        // wx.showToast({ title: res.msg, icon: "none" });
                        console.log(e); //用catch(e)来捕获错误{makePhoneCall:fail cancel}
                    });
                } else {
                }
            });
        },

        //留言咨询
        gotoMessage(e) {
            let url = e.currentTarget.dataset.url;
            uni.navigateTo({
                url
            });
        },

        //确认车牌是否录入
        confirmPlate(e) {
            let status = e.currentTarget.dataset.data.status;
            let billNo = e.currentTarget.dataset.data.billNo;

            if (status == 1) {
                //已录入则不调用接口
                return;
            } else {
                //此处是确认车牌录入逻辑
                const unionId = uni.getStorageSync('unionId') || '';
                const param = {
                    billNo: billNo,
                    unionId: unionId,
                    isInputCar: 1
                };
                util.request(api.billInputCar, param, 'post').then((res) => {
                    if (res.code == 0) {
                        uni.showToast({
                            title: '录入成功！',
                            icon: 'success'
                        });
                    } else {
                        uni.showToast({
                            title: res.msg,
                            icon: 'none'
                        });
                    }
                }); //更改成功后请调用获取列表接口以刷新当前页面

                this.getmyCarOrderLog();
            }
        },

        onCloseMessage() {
            console.log('占位：函数 onCloseMessage 未声明');
        },

        showRefuse() {
            console.log('占位：函数 showRefuse 未声明');
        }
    }
};
</script>
<style>
@import './index.css';
</style>
